package org.redpig.toysys.web;

import org.redpig.toysys.entity.Customers;
import org.redpig.toysys.repository.CustomerRepository;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
@RequestMapping("/customer")
public class CustomerController {

    private CustomerRepository customerRepository;

    public CustomerController(CustomerRepository customerRepository) {
        this.customerRepository = customerRepository;
    }

    @GetMapping("/list")
    public String listAll(Model model) {
        List<Customers> customerList = customerRepository.findAll();
        model.addAttribute("customerList", customerList);
        return "customer";
    }

//    @GetMapping("/id/@{}")
}
